<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>自定义指令</title>
  <script src="../../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <input type="text" v-focus>
    <button>百度一下</button>
  </div>
  
  <script>
    Vue.directive("focus", {
      inserted(domElement) {
        console.log(domElement)
        domElement.focus()
      }
    })
    // 一些自定义指令的应用场景
    // 防抖、图片懒加载、一键 Copy的功能、拖拽、页面水印、权限校验、输入框自动聚焦、相对时间转换、下拉菜单
    var vm = new Vue({
      el: "#app"
    });
  </script>
</body>

</html>